package hao.bk.royalmap;

import java.util.ArrayList;

import hao.bk.searchMap.SearchMapGeneralLayout;
import hao.bk.sql.bo.Location;
import hao.bk.sql.bo.SlideMenu;
import hao.bk.utils.ScreenUtils;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MenuArrayAdapter extends ArrayAdapter<SlideMenu> {
	RoyalMapActivity context = null;
	ArrayList<SlideMenu> menuArray = null;
	int layoutId;

	public MenuArrayAdapter(RoyalMapActivity context, int layoutId, ArrayList<SlideMenu>arr) {
		super(context, layoutId, arr );
		this.context = context;
		this.menuArray = arr;
		this.layoutId= layoutId;
	}
	public View getView(int position, View convertView,
			 ViewGroup parent) {
		final SlideMenu slideMenu = getItem(position);
		ViewHolder holder = null;
		LayoutInflater mInflater = context.getLayoutInflater();
		if (convertView == null) {
			convertView = mInflater.inflate(
					R.layout.slide_menu_list_item, null);
			holder = new ViewHolder();
			holder.logoItemMenu = (ImageView) convertView
					.findViewById(R.id.logo_slide_menu_item);
	
			holder.nameItemMenu = (ExtendedTextView) convertView
					.findViewById(R.id.name_slide_menu_item);
			
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		// Thay đổi kích thước của logo
		/** Lấy về ảnh tương ứng với location
		holder.locationLogo.setImageResource(LogoMapping
				.getIconLogoResourceId(rowItem.getLogo()));
		*/
		//holder.locationLogo.setImageResource(context.getResources().getDrawable(R.drawable.ic_launcher));
		holder.nameItemMenu.setText(slideMenu.getNameItem());
		holder.nameItemMenu
				.setTextSize(ScreenUtils.getTitleSizeItemListView());
		
		AbsListView.LayoutParams param = new AbsListView.LayoutParams(
				LayoutParams.MATCH_PARENT, 80); //set chiều rộng là 80dp
		convertView.setLayoutParams(param);

		return convertView;
		
	}
	private class ViewHolder {
		private ImageView logoItemMenu;
		private ExtendedTextView nameItemMenu;

	}
	

}
